#!/usr/bin/lua -f
readfrom(arg[1])
while 1 do
	b=read(1)
	if not b then break end
	if b=="\31" then
		b=read(1)
		if not b or b=="\139" then break end
	end
end
if not b then
	_ALERT("ERROR\n")
	exit(-1)
end
writeto(strsub(arg[1],1,-5)..".cpio.gz")
write("\31\139")
buf = read(8192)
while buf do
	write(buf)
	buf = read(8192)
end
